package xyz.kongbai121.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.CacheNamespace;
import org.springframework.stereotype.Repository;
import xyz.kongbai121.demo.domain.Opinion;
import xyz.kongbai121.demo.util.MybatisRedisCache;

import java.util.List;

/**
 * 树洞评论 Mapper
 * @author 空白
 */
@Repository
@CacheNamespace(implementation= MybatisRedisCache.class,eviction= MybatisRedisCache.class)
public interface OpinionMapper extends BaseMapper<Opinion> {

    /**
     * 获取对应树洞的所有评论
     * @param treeId        树洞id
     * @return
     */
    List<Opinion> list(Long treeId);

    /**
     * 获取用户收到的意见
     * @param authorOpenid    被评论用户唯一标识
     * @return
     */
    List<Opinion> opinionListByUser(String authorOpenid);

    /**
     * 标记已读
     * @param authorOpenid
     */
    void hasRead(String authorOpenid);

    /**
     * 查询是否有父评论
     * @param opinionId     父评论id
     * @return
     */
    int hasOpinion(Long opinionId);
}
